<?php

namespace IDock\Insurance\TPBX\Response;

use IDock\Http\Response;
use IDock\Insurance\TPBX\Response\AllTPBXResponse;
use IDock\Printer\NonCar\NonCarInquirySinglePrinter;
use IDock\Printer\NonCar\NonCarUnderwritingPrinter;
use IDock\Printer\PremiumUnderwritingPrinter;
use IDock\Visitor\NonCar\NonCarProductVisitor;

class UnderwritingResponse extends AllTPBXResponse
{

    /**
     * @var PremiumUnderwritingPrinter $printer
     */
    public $printer = PremiumUnderwritingPrinter::class;

    public function printerInit(): Response
    {
        $data = $this->getBody()['data']['basePart'] ?? [];

        $this->printer->inquiryNo = '';
        $this->printer->ciInquiryNo = $data['tpTPFApplyNo'] ?? '';
        $this->printer->biInquiryNo = $data['tpBizApplyNo'] ?? '';
        $this->printer->messageTip = $data['attachRulesString'] ?? '';
        $this->printer->argc['nonCarInquiryNo'] = $data['accidentApplyNo'] ?? '';

        if ($data['accidentApplyNo'] ?? '') {
            $nonCarInquiryPrinter = new NonCarUnderwritingPrinter();
            /*** @var $item NonCarProductVisitor */
            $single = new NonCarInquirySinglePrinter();
            $single->inquiryNo = $data['accidentApplyNo'] ?? '';
            $single->planCode = '';
            $single->productCode = '';
            $single->statusCode = 'success';
            $nonCarInquiryPrinter->nonCarSingleAppend($single);
            $this->printer->noCarUnderwritingPrinter = $nonCarInquiryPrinter;
        }
        //人工
        $this->printer->statusCode = 'U3';

        return $this;
    }
}
